#ifndef __IDT_H_f57dbdf4eeb6488ba57a26c18f8494d3__
#define __IDT_H_f57dbdf4eeb6488ba57a26c18f8494d3__

#include <stdint.h>
#include <string.h>

//! i86 defines 256 possible interrupt handlers (0-255)
#define I86_MAX_INTERRUPTS		256

//! must be in the format 0D110, where D is descriptor type
#define I86_IDT_DESC_BIT16		0x06	//00000110
#define I86_IDT_DESC_BIT32		0x0E	//00001110
#define I86_IDT_DESC_RING1		0x40	//01000000
#define I86_IDT_DESC_RING2		0x20	//00100000
#define I86_IDT_DESC_RING3		0x60	//01100000
#define I86_IDT_DESC_PRESENT		0x80	//10000000

typedef void (_cdecl *I86_IR_HANDLER)(void);

typedef struct _idt_descriptor
{
	uint16_t irOffsetLo;
	uint16_t segSelector;
	uint8_t reserved;
	uint8_t flags;
	uint16_t irOffsetHi;
}idt_descriptor,*idt_descriptor_ptr;

void i86_idt_install();
void i86_install_ir(int intNo,I86_IR_HANDLER irq,uint16_t selector,uint16_t flags);
void i86_irq_default_handler();
void i86_idt_initialize(uint16_t selector);

#endif